# Define here the models for your spider middleware
#
# See documentation in:
# https://docs.scrapy.org/en/latest/topics/spider-middleware.html

from scrapy import signals

# useful for handling different item types with a single interface
from itemadapter import is_item, ItemAdapter
import scrapy
from scrapy import Request
from fake_useragent import UserAgent

# 随机U-A
class RandomUA(object):
    def process_request(self, request: Request, spider: scrapy.Spider):
        request.headers['User-Agent'] = UserAgent().chrome